import subprocess

def run_patchcore(model_path, rgb_path, depth_path, save_folder,
                  resize=256, imagesize=224, gpu=0, seed=0):
    command = [
        "python", "bin/load_and_evaluate_patchcore_s.py",
        "--gpu", str(gpu),
        "--seed", str(seed),
        "patch_core_loader",
        "-p", model_path,
        "single_image",
        rgb_path, depth_path,
        "--resize", str(resize),
        "--imagesize", str(imagesize),
        "--save_segmentation_images", save_folder
    ]

    try:
        result = subprocess.run(
            command,
            capture_output=True,
            text=True,
            check=True
        )
        return {"status": "success", "stdout": result.stdout}
    except subprocess.CalledProcessError as e:
        return {"status": "error", "stderr": e.stderr}
